﻿using MediatR;
using Medical.Api.Read.Application.Command.Wms.WmsStoresCommand;
using Medical.Api.Read.Service.WmsService;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Medical.Api.Read.Application.Handler.Wms.WmsStoresHandler
{
    /// <summary>
    /// 待存放物品列表查询处理器，获取所有StoresState=false的物品
    /// </summary>
    public class GetWaitStoresLisatHandler : IRequestHandler<GetWaitStoresLisatCommand, List<WaitStoreDto>>
    {
        /// <summary>
        /// WMS服务
        /// </summary>
        private readonly IWmsService _service;
        /// <summary>
        /// 构造函数，注入WMS服务
        /// </summary>
        public GetWaitStoresLisatHandler(IWmsService service)
        {
            _service = service;
        }
        /// <summary>
        /// 查询所有待存放物品（StoresState=false）
        /// </summary>
        /// <param name="request">待存放物品查询命令</param>
        /// <param name="cancellationToken"></param>
        /// <returns>待存放物品列表</returns>
        public async Task<List<WaitStoreDto>> Handle(GetWaitStoresLisatCommand request, CancellationToken cancellationToken)
        {
            return await _service.GetWaitStoresListAsync();
        }
    }
}
